import requests

import config


# 课程模块接口封装:核心在于依据接口文档实现接口信息封装,重点关注接口如何被调用
#课程添加信息
# https://kdtx-test.itheima.net/api/clues/course
class CourseAPI:
    # 初始化
    def __init__(self):
        self.add_url=config.BASIC_URL+"/api/clues/course"
        self.select_url=config.BASIC_URL+"/api/clues/course/list"
        self.modify_url=config.BASIC_URL+"/api/clues/course"

    #课程添加
    def add_course(self,test_data,token):
        return requests.post(url=self.add_url,json=test_data,headers={"Authorization":token})
    # 课程选择
    def select_course(self,test_data,token):
        return requests.get(url=self.select_url+f"{test_data}",json=test_data,headers={"Authorization":token})
    #课程修改
    def modify_course(self,test_data,token):
        return requests.put(url=self.modify_url,json=test_data,headers={"Authorization":token})
    #课程查询
    def delete_course(self,id,token):
        return requests.delete(url=self.add_url+f"/{id}",headers={"Authorization":token})